package com.wu.server.dao;

import com.wu.server.entity.Tag;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

/**
 * @author Wugs
 * @version 1.0
 * @date 2021/3/6 17:41
 */
@Repository
public interface GoodsTagRepository extends CrudRepository<Tag, Integer> {
    /**
     * 根据tag名称查询数量
     * @param str
     * @return
     */
    @Query(value="select count(*) from jd_shop.tag where tag_name = ?1", nativeQuery = true)
    int getTagNum(String str);

    /**
     * 根据summary降序查询20条标签数据
     * @return
     */
    @Query(value="select * from jd_shop.tag order by tag_summary  desc limit 20;",nativeQuery=true)
    Iterable<Tag> getTagInfo();
}
